#include <fstream>
#include <iostream>

#include <string>

#include "solver.h"

using namespace std;
const int MAX_LENGTH = 500;

int main()
{	
	ifstream input("input.txt");
	ofstream output("output.txt");
	
	int n = 0;
	input >> n;
		
	for(int i = 0; i !=n; ++i){
		string func;
		string operation;

		double a, b;
		double eps;
		double result;

		input >> func;
		input >> operation;				
		input >> a;
		input >> b;
		input >> eps;

		Solver solver(func);
					
		if(operation == "int")
		{			
			result = solver.integrate(a, b, eps);
			output << result << endl;			
		}

		if(operation == "sol")
		{			
			if (solver.solve(a, b, eps, result))
				output << result << endl;
			else 
				output << "No radix" << endl;
		}

	}//for		
	return 0;


}//main

